/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class openCommand extends JMenuItem implements Command{
    
    private JFileChooser fileChooser;
    private JEditorPane panel;
   
    public openCommand(JEditorPane panel)
    {
        this.panel=panel;
        this.fileChooser=new JFileChooser();
    }
    public void execute()
    {
        panel.setBackground(Color.WHITE);

        final JFileChooser Dialogul = new JFileChooser();
        Dialogul.setCurrentDirectory(new File("."));
        

        if (Dialogul.showOpenDialog(openCommand.this)!=JFileChooser.APPROVE_OPTION)
                return;
        Thread fir = new Thread()
        {
                public void run()
                {
                        File fisier = Dialogul.getSelectedFile();
                        try
                        {
                                FileReader intrare = new FileReader (fisier);
                        //      Text.read(intrare, null);
                                intrare.close();
                        }
                        catch(IOException ex)
                        {
                                ex.printStackTrace();
                        }
                }
        };
        fir.start();  
        
    } 

}


